<?php

namespace app\common\model;


use think\facade\Cache;
use think\facade\Validate;
use app\common\model\BaseModel;

use think\Model;

class UserModel extends Model
{

    protected $table = 'cat_user';


    public static function getLoginTimeAttr($value)
    {
        $value = Date("Y-m-d H:i:s", $value);
        return $value;
    }

    /**
     * @Notes:
     * @Interface hasOpenId
     * @param $openId
     * @return array|false|\PDOStatement|string|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @author: Kevin.Yong
     * @Time: 2020/1/8 0008 14:38
     */
    public static function hasOpenId($openId)
    {
        return self::where('open_id', $openId)->find();
    }


    /**
     * @Notes:
     * @Interface hasUserId
     * @param $userId
     * @return array|false|\PDOStatement|string|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @author: Kevin.Yong
     * @Time: 2020/1/8 0008 15:10
     */
    public static function hasUserId($userId)
    {
        return self::where('id', $userId)->find();
    }
}